const path = require('path');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const HtmlWebpckPlugin = require("html-webpack-plugin");
const { VueLoaderPlugin } = require("vue-loader");
const a = {
  mode: "production",
  entry: "./min.js",
  output: {
    //打包后的目录  path.resolve拼接路径 __dirname:表示当前目录
    path: path.resolve(__dirname, "dist"),
    //打包后的文件名
    filename: "bundle.js",
    assetModuleFilename: "imgs/[name]-[hash][ext]",
    clean: true,
  },
  module: {
    rules: [
      // 配置css
      { test: /\.css$/, use: ["style-loader", "css-loader"] },
      { test: /\.s[ac]ss/, use: ["style-loader", "css-loader", "sass-loader"] },
      { test: /\.(jpg|jpeg|png|gif|svg)$/, type: "asset/resource" },
      { test: /\.vue$/, use: ["vue-loader"] },
    ],





  },
  plugins: [
    new MiniCssExtractPlugin({
      filename: "css/home.css",
    }),
    new HtmlWebpckPlugin({
      //指定模板源
      template: "./public/index.html",
      //html输出的文件名
      filename: "index.html",
      minify: false,
    }),
    new VueLoaderPlugin(),
  ],
  devServer: {
    static: './dist',
  },
  resolve: {
    extensions: [".js", ".json", ".vue"],
  },
  performance: {
    // 关闭性能提示
    hints: false,
  },
}
module.exports = a